#!/bin/bash
# version: 1.2
# date: 2022/05/31
# 需要安装依赖包: alsa-utils
# 安装命令: sudo pacman -S alsa-utils

get_volume(){
    STATUS=`amixer sget Master|grep off|wc -l`
    NUM=`amixer get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/"`

    if [ "$STATUS" = "1" ]; then
        printf " 婢 "
    else
        if [ "$NUM" -eq 0 ]; then
            printf " 婢 "
        elif [ "$NUM" -le 33 ]; then
            printf "  %s " "$NUM"
        elif [ "$NUM" -ge 33 ] && [ "$NUM" -le 66 ]; then
            printf " 墳%s " "$NUM"
        else
            printf "  %s " "$NUM"
        fi
    fi
}

get_volume
